/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.soa.service.busi.wx;

import com.lianzt.commondata.AbstractCommonData;
import com.soa.service.BaseService;
import com.soa.util.SystemUtil;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

/**
 *  P90003
 * 按照姓名查询账目
 * @author chang
 */
@Service
public class SearchZd extends BaseService{
    
    private final org.slf4j.Logger log = LoggerFactory.getLogger(SearchZd.class);
    @Override
    public String[] keys() {
        return null;
    }

    @Override
    public void execute(AbstractCommonData in, AbstractCommonData inhead, AbstractCommonData out, AbstractCommonData outhead) {
        String xm = in.getStringValue("xm");
        log.debug("接收到姓名为-------------》{}"+xm);
        try {
            xm = URLDecoder.decode(xm, "utf-8");
        } catch (UnsupportedEncodingException ex) {
            Logger.getLogger(SearchZd.class.getName()).log(Level.SEVERE, null, ex);
        }
        //search_zd_xm = select * from jz_ss where hmsyr=? and sffq='0'
        List<AbstractCommonData> list =  queryList("search_zd_xm", new Object[]{xm});
        List<AbstractCommonData> list_ = new ArrayList<AbstractCommonData>();
        for (int i = 0; i < list.size(); i++) {
            AbstractCommonData abc = list.get(i);
            String hmlx_ = SystemUtil.getColValueDesc("jz_ss.hmlx", abc.getStringValue("hmlx"));
            abc.putStringValue("hmlx_", hmlx_);
            list_.add(abc);
        }
        //统计未付款项
        //select sum(wfk) hj_wfk from jz_ss where hmsyr=? and sffq="0"
        AbstractCommonData tj = queryData("tj_jz_wfk", new Object[]{xm});
        
        out.putStringValue("view", "/wx/fsk_index");
        out.putArrayValue("zd", list_);
        out.putStringValue("bs", "1");
        out.putStringValue("gj", tj.getStringValue("hj_wfk"));
    }
    
    
   
}
